define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/log/index' + location.search,
                    add_url: 'user/log/add',
                    edit_url: 'user/log/edit',
                    del_url: 'user/log/del',
                    multi_url: 'user/log/multi',
                    import_url: 'user/log/import',
                    table: 'get_money_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        // {field: 'uid', title: __('Uid')},
                        {field: 'money', title: __('金币'), operate:'BETWEEN'},
                        {field: 'rmb', title: __('人民币'), operate:'BETWEEN'},
                        {field: 'time', title: __('提现时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'desc', title: __('Desc'), operate: 'LIKE'},
                        {field: 'user.avatar', title: __('头像'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'user.username', title: __('用户名')},
                        {field: 'user.alipay', title: __('支付宝')},
                        {field: 'status', title: __('状态'), searchList: {"1":__('提现成功'),"0":__('审核中'),"2":__('提现失败')}, formatter: Table.api.formatter.normal},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                $(document).on('click', "input[name='row[status]']", function () {
                    var name = $("input[name='row[status]']");
                    name.prop("placeholder", $(this).val() === 0 ? name.data("placeholder-menu") : name.data("placeholder-node"));
                });
                $("input[name='row[status]']:checked").trigger("click");
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});